﻿app.factory('RegisterFactory', ['$http', '$q', '$location', function ($http, $q, $location) {
    var o = {
        status: {}
    };

    o.addAccount = function (newUser) {
        $http({
            url: 'api/Account/Register',
            method: 'POST',
            data: newUser
        }).success(function (response) {
            $location.path("/Login");
        });
    };

    return o;
}]);

//var RegisterFactory = function ($http, $q) {
//    return function (userName,email, password, confirmPassword) {
//        var result = $q.defer();

//        $http({
//            method: 'POST',
//            url: '/api/apinote',
//            data: { Email: email, Password: password, ConfirmPassword: confirmPassword },
//            headers: { 'Content-Type': 'application/json' }
//        })
//		.success(function (response) {
//		    result.resolve(response);
//		})
//		.error(function (response) {
//		    result.reject(response);
//		});

//        return result.promise;
//    }

//}

//RegisterFactory.$inject = ['$http', '$q'];

//headers: { Authorization: 'Bearer ' + localStorage.getItem('token') },